/**
 * 前后端公共的错误码
 */
;(function(factory){
  if (typeof module === 'object' &&  module.exports) {
    module.exports = factory();
  } else if (typeof define === 'function' && define.amd) {
    define(factory);
  }
}(function(){
    return {
      DATA_BASE: -2,
      NO_LOGIN: -1,
      USER_PWD_ERROR: 1,
      NO_MORE: 2,
      PINCHE: 3,
      PINCHE_EDIT: 4,
      NO_DATA: 5,
      PINCHE_FULL: 6,
      PINCHE_HAS_JOINED: 7,
      
      getCodeObj: function(key){
        if(!key){
          return {code: -998, "msg": "error key"};
        }
        if(!this.obj){
          this.obj = {};
          this.obj["0"] = {code: 0};

          this.obj[this.DATA_BASE] = {
              code: this.DATA_BASE,
              msg: "database error"
          };

          this.obj[this.USER_PWD_ERROR] = {
              code: this.USER_PWD_ERROR,
              msg: "login user or pwd error"
          };

          this.obj[this.NO_MORE] = {
              code: this.NO_MORE,
              msg: "no more list data"
          };

          this.obj[this.PINCHE] = {
              code: this.PINCHE,
              msg: "pinche data error"
          };

          this.obj[this.PINCHE_FULL] = {
              code: this.PINCHE_FULL,
              msg: "pinche person is full"
          };

          this.obj[this.PINCHE_HAS_JOINED] = {
              code: this.PINCHE_HAS_JOINED,
              msg: "you have joined the order"
          };

          this.obj[this.NO_LOGIN] = {
              code: this.NO_LOGIN,
              msg: "no login"
          };

          this.obj[this.NO_DATA] = {
              code: this.NO_DATA,
              msg: "no data"
          };

        }
        if(this.obj[key]){
          return this.obj[key];
        }else{
          return {code: -999, msg: "unknown error", key: key};
        }        
      } 
    };
}));
